<?php
include_once "../header1.php";
?>
<script type="text/javascript">
function cleartbox()
{	
	document.getElementById("Sea_ResTea").innerHTML="";
}
</script>
<script type="text/javascript">
function getHttpRequest()
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}
function showHint(str)
{
var xmlhttp;    
if (str=="")
  {
  document.getElementById("List").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("List").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","Tea_names.php?q="+str,true);
xmlhttp.send();
}
function fill(val)
{ 
document.resourceteam.TeaName.value=val;
document.getElementById("List").innerHTML="";
}
</script>
<script type="text/javascript">
function getRes(hin)
{
var xmlhttp;    
if (hin=="")
  {
  document.getElementById("Sea_ResTea").innerHTML="<font class='err'><img src='../images/alert.jpg' width='12' height='12'/> Please enter the Teacher's name!</font>";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("Sea_ResTea").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","search.php?q="+hin,true);
xmlhttp.send();
}
</script>
</head>
<body>
<?php
include_once ("../Login/databaseconnection.php");

if(!loggedin())
{
	require_once ("../index.php");
}
   else
   {
     $action=$_GET['action'];
   if($_GET['action']=="teacher")
   {
   $T_NIC=$_GET['t'];
}
 if($_GET['action']=="school")
   {   
   $S_Id=$_GET['s'];   
}
 if($_GET['action']=="fromdate")
   {  
  $Fr_Date=$_GET['f'];
   }
   if($_GET['action']=="training")
   {  
  $Tra_Id=$_GET['tra'];
      }
	   if($action=="training")
   {   
 if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
{
$nics="";
 $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
    $gettea=mysql_query("SELECT * FROM resource_team WHERE Training_Id='$Tra_Id'"); 
   while($rotea=mysql_fetch_array($gettea))
   {
$T_NIC_No=$rotea['T_NIC_Number']; 
  $getsc=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$T_NIC_No'"); 
if($rowsc=mysql_fetch_array($getsc))
{
if($rowsc['School_Id']==$Own_School_Id)
{
if(empty($nics))
{
$nics=$T_NIC_No;
}
else
{
$nics=$nics.",".$T_NIC_No;
}
}
}
}
   	if($nics=="")
	{
		$_SESSION['errorno']="Very sorry there is no result for your search!";
	}
	}
}
else if($_SESSION['Access_Type']=="Administrator")
{
if(mysql_num_rows(mysql_query("SELECT * FROM resource_team WHERE Training_Id='$Tra_Id'"))==0)
	{
		$_SESSION['errorno']="Very sorry there is no result for your search!";
	}
}
else
   {
   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
   }
   }
   if($action=="fromdate")
   {   
 if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
{
$nics="";
 $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
    $gettea=mysql_query("SELECT * FROM resource_team WHERE From_Date='$Fr_Date'"); 
   while($rotea=mysql_fetch_array($gettea))
   {
$T_NIC_No=$rotea['T_NIC_Number']; 
  $getsc=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$T_NIC_No'"); 
if($rowsc=mysql_fetch_array($getsc))
{
if($rowsc['School_Id']==$Own_School_Id)
{
if(empty($nics))
{
$nics=$T_NIC_No;
}
else
{
$nics=$nics.",".$T_NIC_No;
}
}
}
}
   	if($nics=="")
	{
		$_SESSION['errorno']="Very sorry there is no result for your search!";
	}
	}
}
else if($_SESSION['Access_Type']=="Administrator")
{
if(mysql_num_rows(mysql_query("SELECT * FROM resource_team WHERE From_Date='$Fr_Date'"))==0)
	{
		$_SESSION['errorno']="Very sorry there is no result for your search!";
	}
}
else
   {
   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
   }
   }
   if($action=="teacher")
   {   
 if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
{
   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
    $getthsch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$T_NIC'"); 
   if($roSch=mysql_fetch_array($getthsch))
   {
$Sch_Id=$roSch['School_Id'];   
   if($Sch_Id==$Own_School_Id)
	{
	if(mysql_num_rows(mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$T_NIC'"))==0)
	{
		$_SESSION['errorno']="Very sorry there is no result for your search!";
	}
	}
	else
   {
   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
   }
	}
	else
   {
   $_SESSION['errornotallo']="This person's record is not registered into Teacher's record!";
   }
}
}
else if($_SESSION['Access_Type']=="Administrator")
{
if(mysql_num_rows(mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$T_NIC'"))==0)
	{
		$_SESSION['errorno']="Very sorry there is no result for your search!";
	}
}
else
   {
   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
   }
   }
     if($action=="school")
   {   
 if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
{
   $NIC_Number=$_SESSION['NIC_Number'];
   $T_S_Nics="";
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
     if($S_Id==$Own_School_Id)
	{
	  $get_Teachers=mysql_query("SELECT * FROM teacher WHERE School_Id='$S_Id'");
	  while($rteach=mysql_fetch_array($get_Teachers))
	  {
	  $Tea_nic_no=$rteach['T_NIC_Number'];
	  if(mysql_num_rows(mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$Tea_nic_no'"))!=0)
	{
	if(empty($T_S_Nics))
	{
	$T_S_Nics=$Tea_nic_no;
	}
	else
	{
	$T_S_Nics=$T_S_Nics.",".$Tea_nic_no;
	}
	}
	}
	if($T_S_Nics=="")
	{
		$_SESSION['errorno']="Very sorry there is no result for your search!";
	}
	}
}
}
else if($_SESSION['Access_Type']=="Administrator")
{
$T_S_Nics="";
 $get_Teachers=mysql_query("SELECT * FROM teacher WHERE School_Id='$S_Id'");
	  while($rteach=mysql_fetch_array($get_Teachers))
	  {
	  $Tea_nic_no=$rteach['T_NIC_Number'];
	  if(mysql_num_rows(mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$Tea_nic_no'"))!=0)
	{
	if(empty($T_S_Nics))
	{
	$T_S_Nics=$Tea_nic_no;
	}
	else
	{
	$T_S_Nics=$T_S_Nics.",".$Tea_nic_no;
	}
	}
	}
	if($T_S_Nics=="")
	{
		$_SESSION['errorno']="Very sorry there is no result for your search!";
	}
}
else
   {
   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
   }
   }
?>
<?php
include_once "../header2.php";
?>
<?php
include_once "topmenu.php";
?>
<div id="content">
	<div id="main">
	  <div id="bodyfield">
<div id="lefttable">
<table width="530" border="0" class="tablefontv">
<tr><td width="47" height="43" class="err">
<?php
if(isset($_SESSION['errornotallo']))
	{
	echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errornotallo'];
		unset($_SESSION['errornotallo']);
	}
	if(isset($_SESSION['errorno']))
	{
	echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errorno'];
		unset($_SESSION['errorno']);
	}
?>
</td></tr></table>
  <table width="530" border="0" class="tablefontv">
  <tr><form name="resourceteam">
  <td width="47" height="43">&nbsp;</td>
      <td width="131">Teacher's Name:</td>
      <td width="149">
	  <?php
	   $tnam=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$T_NIC'");
	  if($rot=mysql_fetch_array($tnam))
	  {
	  $Tea_Name=$rot['First_Name']." ".$rot['Last_Name'];
	  }
	  	  echo "<input type='text' id='TeaName' name='TeaName' onKeyUp='showHint(this.value)' value='$Tea_Name' onClick='cleartbox()' size='35'/>";
	  ?>
	  </td>
      <td width="33"><input type="button" class="searchid" onClick="getRes(TeaName.value)"></td>
      <td width="148">
     </td></form></tr>
   <tr>
  <td>
  </td>
  <td>
  </td><td>
 <div class="suggestionListPro" id="List"></div> </td>
 <td>
 </td>
 <td></td>
  </tr></table>
  <br/>
<div id="Sea_ResTea"> 
<?php
if($action=="training")
   {   
 if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
{
$nics="";
 $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
    $gettea=mysql_query("SELECT * FROM resource_team WHERE Training_Id='$Tra_Id'"); 
   while($rotea=mysql_fetch_array($gettea))
   {
$T_NIC_No=$rotea['T_NIC_Number']; 
  $getsc=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$T_NIC_No'"); 
if($rowsc=mysql_fetch_array($getsc))
{
if($rowsc['School_Id']==$Own_School_Id)
{
if(empty($nics))
{
$nics=$T_NIC_No;
}
else
{
$nics=$nics.",".$T_NIC_No;
}
}
}
}
if($nics!="")
{
$nat_no=explode(",",$nics);
   if(count($nat_no)>0)
	   {
	   $colu="";
	   $sql=mysql_query("SHOW COLUMNS FROM resource_team");
if(count($nat_no)>11)
{
echo '<div style="width:700px; height:400px; overflow-Y:scroll; ">';
}
      echo '<table border="1" class="tablefontv">';
	  echo "<tr bgcolor='#6AB5FF'>";
	while($rowc=mysql_fetch_row($sql))
  {
  if(empty($colu))
  {
  $colu=$rowc[0];
  }
  else
  {
   $colu=$colu.",".$rowc[0];
  }
  if($rowc[0]=="Training_Id")
  {
  echo "<td>Training Name</td>";
  }
  else
  {
  echo "<td>".str_replace("_"," ",$rowc[0])."</td>";
  }
  }
  echo "</tr>";
 $columns=explode(",",$colu);
 for($f=0;$f<count($nat_no);$f++)
 {
 $no=$nat_no[$f];
  $Exc_que="SELECT * FROM resource_team WHERE T_NIC_Number='$no' AND Training_Id='$Tra_Id'";
 $result=mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$no' AND Training_Id='$Tra_Id'");
 if($result)
 {
    while($row=mysql_fetch_array($result))
  {
 echo "<tr bgcolor='#999999'>";
  for($cv=0;$cv<mysql_num_rows($sql);$cv++)
	{
	 $col_name=$columns[$cv];
	    if($col_name=="Training_Id")
  {
  $res=mysql_query("SELECT * FROM  training WHERE Training_Id='".$row[$col_name]."'");
if($rowc=mysql_fetch_array($res))
{
$Training_Name=$rowc['Training_Name'];
}
  echo "<td>".$Training_Name."</td>";
  }
  else
  {
  echo "<td>".$row[$col_name]."</td>";
  }
	}
	  echo '</tr>';
	}
	}
	}
	echo '</table>';
if(count($nat_no)>11)
{
echo '</div>';
}
}
	}
}
}
else if($_SESSION['Access_Type']=="Administrator")
{
 $Exc_que="SELECT * FROM resource_team WHERE Training_Id='$Tra_Id'";
 $result=mysql_query("SELECT * FROM resource_team WHERE Training_Id='$Tra_Id'");
	 if($result)
 {
    $colu="";
	   $sql=mysql_query("SHOW COLUMNS FROM resource_team");
if(mysql_num_rows($result)>11)
{
echo '<div style="width:700px; height:400px; overflow-Y:scroll; ">';
}
      echo '<table border="1" class="tablefontv">';
	  echo "<tr bgcolor='#6AB5FF'>";
	while($rowc=mysql_fetch_row($sql))
  {
  if(empty($colu))
  {
  $colu=$rowc[0];
  }
  else
  {
   $colu=$colu.",".$rowc[0];
  }
  if($rowc[0]=="Training_Id")
  {
  echo "<td>Training Name</td>";
  }
  else
  {
  echo "<td>".str_replace("_"," ",$rowc[0])."</td>";
  }
  }
  echo "</tr>";
 $columns=explode(",",$colu);
    while($row=mysql_fetch_array($result))
  {
 echo "<tr bgcolor='#999999'>";
  for($cv=0;$cv<mysql_num_rows($sql);$cv++)
	{
	 $col_name=$columns[$cv];
	  if($col_name=="Training_Id")
  {
  $res=mysql_query("SELECT * FROM  training WHERE Training_Id='".$row[$col_name]."'");
if($rowc=mysql_fetch_array($res))
{
$Training_Name=$rowc['Training_Name'];
}
  echo "<td>".$Training_Name."</td>";
  }
  else
  {
  echo "<td>".$row[$col_name]."</td>";
  }
	}
	  echo '</tr>';
	}
	echo '</table>';
if(mysql_num_rows($result)>11)
{
echo '</div>';
}
 }
}
   }
if($action=="fromdate")
   {   
 if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
{
$nics="";
 $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
    $gettea=mysql_query("SELECT * FROM resource_team WHERE From_Date='$Fr_Date'"); 
   while($rotea=mysql_fetch_array($gettea))
   {
$T_NIC_No=$rotea['T_NIC_Number']; 
  $getsc=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$T_NIC_No'"); 
if($rowsc=mysql_fetch_array($getsc))
{
if($rowsc['School_Id']==$Own_School_Id)
{
if(empty($nics))
{
$nics=$T_NIC_No;
}
else
{
$nics=$nics.",".$T_NIC_No;
}
}
}
}
if($nics!="")
{
$nat_no=explode(",",$nics);
   if(count($nat_no)>0)
	   {
	   $colu="";
	   $sql=mysql_query("SHOW COLUMNS FROM resource_team");
if(count($nat_no)>11)
{
echo '<div style="width:700px; height:400px; overflow-Y:scroll; ">';
}
      echo '<table border="1" class="tablefontv">';
	  echo "<tr bgcolor='#6AB5FF'>";
	while($rowc=mysql_fetch_row($sql))
  {
  if(empty($colu))
  {
  $colu=$rowc[0];
  }
  else
  {
   $colu=$colu.",".$rowc[0];
  }
 if($rowc[0]=="Training_Id")
  {
  echo "<td>Training Name</td>";
  }
  else
  {
  echo "<td>".str_replace("_"," ",$rowc[0])."</td>";
  }
  }
  echo "</tr>";
 $columns=explode(",",$colu);
 for($f=0;$f<count($nat_no);$f++)
 {
 $no=$nat_no[$f];
 $Exc_que="SELECT * FROM resource_team WHERE T_NIC_Number='$no' AND From_Date='$Fr_Date'";
 $result=mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$no' AND From_Date='$Fr_Date'");
 if($result)
 {
    while($row=mysql_fetch_array($result))
  {
 echo "<tr bgcolor='#999999'>";
  for($cv=0;$cv<mysql_num_rows($sql);$cv++)
	{
	 $col_name=$columns[$cv];
	   if($col_name=="Training_Id")
  {
  $res=mysql_query("SELECT * FROM  training WHERE Training_Id='".$row[$col_name]."'");
if($rowc=mysql_fetch_array($res))
{
$Training_Name=$rowc['Training_Name'];
}
  echo "<td>".$Training_Name."</td>";
  }
  else
  {
  echo "<td>".$row[$col_name]."</td>";
  }
	}
	  echo '</tr>';
	}
	}
	}
	echo '</table>';
if(count($nat_no)>11)
{
echo '</div>';
}
}
	}
}
}
else if($_SESSION['Access_Type']=="Administrator")
{
$Exc_que="SELECT * FROM resource_team WHERE From_Date='$Fr_Date'";
 $result=mysql_query("SELECT * FROM resource_team WHERE From_Date='$Fr_Date'");
	 if($result)
 {
    $colu="";
	   $sql=mysql_query("SHOW COLUMNS FROM resource_team");
if(mysql_num_rows($result)>11)
{
echo '<div style="width:700px; height:400px; overflow-Y:scroll; ">';
}
      echo '<table border="1" class="tablefontv">';
	  echo "<tr bgcolor='#6AB5FF'>";
	while($rowc=mysql_fetch_row($sql))
  {
  if(empty($colu))
  {
  $colu=$rowc[0];
  }
  else
  {
   $colu=$colu.",".$rowc[0];
  }
 if($rowc[0]=="Training_Id")
  {
  echo "<td>Training Name</td>";
  }
  else
  {
  echo "<td>".str_replace("_"," ",$rowc[0])."</td>";
  }
  }
  echo "</tr>";
 $columns=explode(",",$colu);
    while($row=mysql_fetch_array($result))
  {
 echo "<tr bgcolor='#999999'>";
  for($cv=0;$cv<mysql_num_rows($sql);$cv++)
	{
	 $col_name=$columns[$cv];
	  if($col_name=="Training_Id")
  {
  $res=mysql_query("SELECT * FROM  training WHERE Training_Id='".$row[$col_name]."'");
if($rowc=mysql_fetch_array($res))
{
$Training_Name=$rowc['Training_Name'];
}
  echo "<td>".$Training_Name."</td>";
  }
  else
  {
  echo "<td>".$row[$col_name]."</td>";
  }
	}
	  echo '</tr>';
	}
	echo '</table>';
if(mysql_num_rows($result)>11)
{
echo '</div>';
}
 }
}
   }
   if($action=="teacher")
   {   
 if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
{
   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
    $getthsch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$T_NIC'"); 
   if($roSch=mysql_fetch_array($getthsch))
   {
$Sch_Id=$roSch['School_Id'];   
   if($Sch_Id==$Own_School_Id)
	{
	$Exc_que="SELECT * FROM resource_team WHERE T_NIC_Number='$T_NIC'";
	$result=mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$T_NIC'");
	}
		}
	}
}
else if($_SESSION['Access_Type']=="Administrator")
{
$Exc_que="SELECT * FROM resource_team WHERE T_NIC_Number='$T_NIC'";
$result=mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$T_NIC'");
}
 if($result)
 {
    $colu="";
	   $sql=mysql_query("SHOW COLUMNS FROM resource_team");
if(mysql_num_rows($result)>11)
{
echo '<div style="width:700px; height:400px; overflow-Y:scroll; ">';
}
      echo '<table border="1" class="tablefontv">';
	  echo "<tr bgcolor='#6AB5FF'>";
	while($rowc=mysql_fetch_row($sql))
  {
  if(empty($colu))
  {
  $colu=$rowc[0];
  }
  else
  {
   $colu=$colu.",".$rowc[0];
  }
 if($rowc[0]=="Training_Id")
  {
  echo "<td>Training Name</td>";
  }
  else
  {
  echo "<td>".str_replace("_"," ",$rowc[0])."</td>";
  }
  }
  echo "</tr>";
 $columns=explode(",",$colu);
    while($row=mysql_fetch_array($result))
  {
 echo "<tr bgcolor='#999999'>";
  for($cv=0;$cv<mysql_num_rows($sql);$cv++)
	{
	 $col_name=$columns[$cv];
	  if($col_name=="Training_Id")
  {
  $res=mysql_query("SELECT * FROM  training WHERE Training_Id='".$row[$col_name]."'");
if($rowc=mysql_fetch_array($res))
{
$Training_Name=$rowc['Training_Name'];
}
  echo "<td>".$Training_Name."</td>";
  }
  else
  {
  echo "<td>".$row[$col_name]."</td>";
  }
	}
	  echo '</tr>';
	}
	echo '</table>';
if(mysql_num_rows($result)>11)
{
echo '</div>';
}
 }
   }
     if($action=="school")
   {   
 if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
{
   $NIC_Number=$_SESSION['NIC_Number'];
   $T_S_Nics="";
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
     if($S_Id==$Own_School_Id)
	{
	  $get_Teachers=mysql_query("SELECT * FROM teacher WHERE School_Id='$S_Id'");
	  while($rteach=mysql_fetch_array($get_Teachers))
	  {
	  $Tea_nic_no=$rteach['T_NIC_Number'];
	  if(mysql_num_rows(mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$Tea_nic_no'"))!=0)
	{
	if(empty($T_S_Nics))
	{
	$T_S_Nics=$Tea_nic_no;
	}
	else
	{
	$T_S_Nics=$T_S_Nics.",".$Tea_nic_no;
	}
	}
	}
	if($T_S_Nics!="")
	{
		$nat_i_no=explode(",",$T_S_Nics);
   if(count($nat_i_no)>0)
	   {
	   $colu="";
	   $sql=mysql_query("SHOW COLUMNS FROM resource_team");
if(count($nat_no)>11)
{
echo '<div style="width:700px; height:400px; overflow-Y:scroll; ">';
}
      echo '<table border="1" class="tablefontv">';
	  echo "<tr bgcolor='#6AB5FF'>";
	while($rowc=mysql_fetch_row($sql))
  {
  if(empty($colu))
  {
  $colu=$rowc[0];
  }
  else
  {
   $colu=$colu.",".$rowc[0];
  }
 if($rowc[0]=="Training_Id")
  {
  echo "<td>Training Name</td>";
  }
  else
  {
  echo "<td>".str_replace("_"," ",$rowc[0])."</td>";
  }
  }
  echo "</tr>";
 $columns=explode(",",$colu);
 for($f=0;$f<count($nat_i_no);$f++)
 {
 $n_no=$nat_i_no[$f];
 $Exc_que="SELECT * FROM resource_team WHERE T_NIC_Number='$n_no'";
 $result=mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$n_no'");
 if($result)
 {
    while($row=mysql_fetch_array($result))
  {
 echo "<tr bgcolor='#999999'>";
  for($cv=0;$cv<mysql_num_rows($sql);$cv++)
	{
	 $col_name=$columns[$cv];
	   if($col_name=="Training_Id")
  {
  $res=mysql_query("SELECT * FROM  training WHERE Training_Id='".$row[$col_name]."'");
if($rowc=mysql_fetch_array($res))
{
$Training_Name=$rowc['Training_Name'];
}
  echo "<td>".$Training_Name."</td>";
  }
  else
  {
  echo "<td>".$row[$col_name]."</td>";
  }
	}
	  echo '</tr>';
	}
	}
	}
	echo '</table>';
if(count($nat_no)>11)
{
echo '</div>';
}
}
	}
	}
}
}
else if($_SESSION['Access_Type']=="Administrator")
{
$T_S_Nics="";
 $get_Teachers=mysql_query("SELECT * FROM teacher WHERE School_Id='$S_Id'");
	  while($rteach=mysql_fetch_array($get_Teachers))
	  {
	  $Tea_nic_no=$rteach['T_NIC_Number'];
	  if(mysql_num_rows(mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$Tea_nic_no'"))!=0)
	{
	if(empty($T_S_Nics))
	{
	$T_S_Nics=$Tea_nic_no;
	}
	else
	{
	$T_S_Nics=$T_S_Nics.",".$Tea_nic_no;
	}
	}
	}
	if($T_S_Nics!="")
	{
		$nat_i_no=explode(",",$T_S_Nics);
   if(count($nat_i_no)>0)
	   {
	   $colu="";
	   $sql=mysql_query("SHOW COLUMNS FROM resource_team");
if(count($nat_no)>11)
{
echo '<div style="width:700px; height:400px; overflow-Y:scroll; ">';
}
      echo '<table border="1" class="tablefontv">';
	  echo "<tr bgcolor='#6AB5FF'>";
	while($rowc=mysql_fetch_row($sql))
  {
  if(empty($colu))
  {
  $colu=$rowc[0];
  }
  else
  {
   $colu=$colu.",".$rowc[0];
  }
 if($rowc[0]=="Training_Id")
  {
  echo "<td>Training Name</td>";
  }
  else
  {
  echo "<td>".str_replace("_"," ",$rowc[0])."</td>";
  }
  }
  echo "</tr>";
 $columns=explode(",",$colu);
 for($f=0;$f<count($nat_i_no);$f++)
 {
 $n_no=$nat_i_no[$f];
 $Exc_que="SELECT * FROM resource_team WHERE T_NIC_Number='$n_no'";
 $result=mysql_query("SELECT * FROM resource_team WHERE T_NIC_Number='$n_no'");
 if($result)
 {
    while($row=mysql_fetch_array($result))
  {
 echo "<tr bgcolor='#999999'>";
  for($cv=0;$cv<mysql_num_rows($sql);$cv++)
	{
	 $col_name=$columns[$cv];
	  if($col_name=="Training_Id")
  {
  $res=mysql_query("SELECT * FROM  training WHERE Training_Id='".$row[$col_name]."'");
if($rowc=mysql_fetch_array($res))
{
$Training_Name=$rowc['Training_Name'];
}
  echo "<td>".$Training_Name."</td>";
  }
  else
  {
  echo "<td>".$row[$col_name]."</td>";
  }
	}
	  echo '</tr>';
	}
	}
	}
	echo '</table>';
if(count($nat_no)>11)
{
echo '</div>';
}
}
	}
}

   }
   if($result)
{
$Exc_quer=str_replace("'","@",$Exc_que);
echo "<form action='../exportreport.php' method='post'><input type='submit' name='ToExcel' class='print' value=''/><input type='hidden' value='$Exc_quer' name='query'/><input type='hidden' value='resource_team' name='Exc_table_name'/></form>";
}
   ?>
</div>
</div>
  </div>
</div>
</div>
<div id="sidebar">
<br/>
<div id="partners" class="boxed">
			<h2 class="title">RESOURCE TEAM</h2>
            </div>
<?php
include_once "menu.php";
?>
 <?php
include_once "../footer.php";
?>
<?php
}
?>
</body>
</html>